package vip.xiaonuo.modular.cms.config;

import com.xkcoding.http.support.Http;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ProjectName: snowy_layui_cms
 * @Package: vip.xiaonuo.modular.cms.config
 * @ClassName: WebConfig
 * @Author: liubaihan
 * @Description: web配置
 * @Date: 2022/6/27 17:42
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    public HttpServletInterceptor getHttpServletInterceptor(){
        return new HttpServletInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //  /**表示拦截所有请求
        String[] addPath = {
                "/",
                "/getCatalogInfo",
                "/getArticleContentByArticleId/**",
                "/getPage/**",
        };
        // 放行getStudent和getUser两个请求：其中getUser请求没有对应的处理器
        //String[] excludePath = {"/getStudent","/getUser"};
        registry.addInterceptor(getHttpServletInterceptor()).addPathPatterns(addPath);
    }

}
